package com.ruoyi.system.controller;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.domain.RedisDataInfo;
import com.ruoyi.system.service.ISysRedisValueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wjialong
 */
@RestController
@RequestMapping("/redis/value")
public class SysRedisValueController {
    @Autowired
    ISysRedisValueService redisValueService;

    /**
     * 获取单个value
     *
     * @param redisDataInfo
     * @return
     */
    @GetMapping
    public AjaxResult getValue(RedisDataInfo redisDataInfo) {
        if (!redisValueService.getValue(redisDataInfo)) {
            return AjaxResult.error("查询失败");
        }
        return AjaxResult.success(redisDataInfo);
    }

    @PostMapping
    public AjaxResult addValue(@RequestBody RedisDataInfo redisDataInfo) {
        redisValueService.addValue(redisDataInfo);
        return AjaxResult.success();
    }

    @PutMapping
    public AjaxResult updateValue(@RequestBody RedisDataInfo redisDataInfo) {
        redisValueService.updateValue(redisDataInfo);
        return AjaxResult.success();
    }

    @DeleteMapping
    public AjaxResult deleteListValue(@RequestBody RedisDataInfo redisDataInfo) {
        redisValueService.deleteValue(redisDataInfo);
        return AjaxResult.success();
    }

}
